package com.tn.tgt.easybuy.web;

import com.tn.tgt.easybuy.model.EbNews;
import com.tn.tgt.easybuy.model.EbProductCategory;
import com.tn.tgt.easybuy.service.EbNewsService;
import com.tn.tgt.easybuy.service.EbProductCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/news")
public class NewsController {
    @Autowired
    private EbNewsService ebNewsService;

    @Autowired
    EbProductCategoryService ebProductCategoryService;

    @RequestMapping("/detail")
    public  String detail(Model model,Integer enId){
        EbNews ebNewsDetail=ebNewsService.detail(enId);
        Map<String, List<EbProductCategory>> categoryMap=ebProductCategoryService.selectBigAndSmallCate();
        model.addAttribute("detail",ebNewsDetail);
        model.addAttribute("categoryMap",categoryMap);
        return "news-view";


    }
}
